package com.study.service.impl;

import com.alibaba.fastjson.JSON;
import com.study.source.LogisticSource;
import lombok.extern.slf4j.Slf4j;
import order.LogisticMessage;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.Payload;

@Slf4j
@EnableBinding(LogisticSource.class)
public class LogisticsServiceImpl {

    @StreamListener("logisticsOutput")
    public void consumerLogisticsMessage(@Payload Object payload){

        LogisticMessage logisticMessage = JSON.parseObject(
                payload.toString(),LogisticMessage.class
        );

        log.info("反序列化得到的logisticMessage：{}",logisticMessage);
    }
}
